package com.info.zhiduoduo.repository.dto.maker;

import org.springframework.beans.BeanUtils;

import java.math.BigDecimal;

import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class MakerYearAmountDto {

	@ApiModelProperty("当前年份")
	private Integer year;
	@ApiModelProperty(" 交易额")
	private BigDecimal zddAmount;
	@ApiModelProperty("智众包交易额")
	private BigDecimal crowdsourceAmount;
	@ApiModelProperty(" 交易额")
	private BigDecimal taxerAmount;
	@ApiModelProperty("纯代理交易额")
	private BigDecimal agentTaxerAmount;
	@ApiModelProperty("委托接单交易额")
	private BigDecimal entrustAmount;
	@ApiModelProperty("创客团交易额")
	private BigDecimal makerGrouponAmount;
	@ApiModelProperty("交易额小计")
	private BigDecimal totalAmount;

	public static MakerYearAmountDto of(Integer year) {
		return new MakerYearAmountDto().setYear(year)
				.setZddAmount(BigDecimal.ZERO)
				.setCrowdsourceAmount(BigDecimal.ZERO)
				.setTaxerAmount(BigDecimal.ZERO)
				.setAgentTaxerAmount(BigDecimal.ZERO)
				.setEntrustAmount(BigDecimal.ZERO)
				.setMakerGrouponAmount(BigDecimal.ZERO)
				.setTotalAmount(BigDecimal.ZERO);
	}

	public MakerYearAmountDto add(MakerYearAmountDto other) {
		this.zddAmount = this.zddAmount.add(other.zddAmount);
		this.crowdsourceAmount = this.crowdsourceAmount.add(other.crowdsourceAmount);
		this.taxerAmount = this.taxerAmount.add(other.taxerAmount);
		this.agentTaxerAmount = this.agentTaxerAmount.add(other.agentTaxerAmount);
		this.entrustAmount = this.entrustAmount.add(other.entrustAmount);
		this.makerGrouponAmount = this.makerGrouponAmount.add(other.makerGrouponAmount);
		this.totalAmount = this.totalAmount.add(other.totalAmount);
		return this;
	}

	public void copy(MakerYearAmountDto monthBusinessGross) {
		BeanUtils.copyProperties(monthBusinessGross, this, "id");
	}
}
